package com.infoland.afanmall.model.youXuan.adapter;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.FragmentActivity;
import android.support.v7.widget.AppCompatImageView;
import android.view.View;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.target.SimpleTarget;
import com.bumptech.glide.request.transition.Transition;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.chad.library.adapter.base.entity.MultiItemEntity;
import com.infoland.afanmall.R;
import com.infoland.afanmall.base.util.LogKit;
import com.infoland.afanmall.base.util.ToolsKit;
import com.infoland.afanmall.model.youXuan.entity.TimeByEntity;
import com.infoland.afanmall.model.youXuan.entity.YouXuanType;

import java.util.List;

public class TimeByAdapter extends BaseQuickAdapter<MultiItemEntity, BaseViewHolder> {

    private int layoutPosition = 0;
    private Context context;
    private FragmentActivity activity;

    public TimeByAdapter(int layoutResId, List data, Context context, FragmentActivity activity) {
        super(layoutResId, data);
        this.context = context;
        this.activity = activity;
    }

    @Override
    protected void convert(BaseViewHolder helper, MultiItemEntity item) {
        int position = helper.getAdapterPosition();
        TimeByEntity.ListBean objectBean = (TimeByEntity.ListBean) item;
        ToolsKit.setImgView(objectBean.getF_url(), helper.getView(R.id.ys_time_by_img));
        helper.setText(R.id.ys_tx_1, "[" + objectBean.getG_introduction() + "]");
        helper.setText(R.id.ys_tx_2, objectBean.getG_name() + "");
        LogKit.E("  objectBean.getG_price() ", "  " + objectBean.getG_price());
        LogKit.E("  objectBean.getG_price() ", "  " + objectBean.getG_origin_price());
        helper.setText(R.id.ys_tx_price1, "￥" + objectBean.getG_price());
        helper.setText(R.id.ys_tx_price2, "￥" + objectBean.getG_origin_price());
        ToolsKit.setTextDelete(helper.getView(R.id.ys_tx_price2));
        ToolsKit.setTextBlob(helper.getView(R.id.ys_tx_1));

        helper.getView(R.id.ys_time_by_img).setOnClickListener(v -> {
            bkLinster.onClick(helper, YouXuanType.TIME_BY, position, item, "img");
        });
        helper.getView(R.id.bk_by).setOnClickListener(v -> {
            bkLinster.onClick(helper, YouXuanType.TIME_BY, position, item, "btn");
        });
    }


    public interface BkLinster {
        /**
         * @param holder
         * @param itemType
         * @param position
         * @param item_bk
         */
        void onClick(BaseViewHolder holder, int itemType, int position, Object item_bk, String item_type);
    }

    private BkLinster bkLinster;

    public void setBKLinster(BkLinster bkLinster) {
        this.bkLinster = bkLinster;
    }

}
